package getImg

import (
	"context"

	"server-go/api/reward/internal/svc"
	"server-go/api/reward/internal/types"
	"server-go/api/reward/internal/util"

	"github.com/zeromicro/go-zero/core/logx"
)

type UploadHeadImgLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUploadHeadImgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadHeadImgLogic {
	return &UploadHeadImgLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UploadHeadImgLogic) UploadHeadImg(req *types.UploadHeadImgInput) (resp *types.UploadHeadImgOutput, err error) {
	// 写入文件
	imgPath := "../public/images/" + req.UserName + ".jpg"
	err = util.CreateSelfFile(imgPath, req.HeadImgFile)
	if err != nil {
		return nil, err
	}
	return nil, nil
}
